// app/model/user_shortcut_model.js
'use strict';

module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;

  const UserShortcut = app.model.define('user_shortcut', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    userId: {
      type: INTEGER,
      allowNull: false,
      field: 'user_id', // 明确指定数据库字段名
      comment: '用户ID'
    },
    type: {
      type: STRING(20),
      allowNull: false,
      comment: '快捷键类型: global(全局), module(模块)'
    },
    moduleId: {
      type: STRING(50),
      allowNull: true,
      field: 'module_id', // 明确指定数据库字段名
      comment: '模块ID'
    },
    key: {
      type: STRING(20),
      allowNull: false,
      comment: '快捷键'
    },
    action: {
      type: STRING(100),
      allowNull: false,
      comment: '操作'
    },
    description: {
      type: STRING(200),
      allowNull: true,
      comment: '描述'
    }
  }, {
    tableName: 'user_shortcuts',
    underscored: true,
    comment: '用户快捷键表'
  });

  return UserShortcut;
};